package work;

public class Polymorphic {
    public static void main(String[] args) {
        //向下转型的本质：是先向上造型。
        //多态，永远不可能转换为比对象小的类型


        Azz o1 = new Czz();
        o1.say();
        Bzz o2 = (Bzz)o1;
        o2.say();
        Czz o3 = (Czz)o1;
        o3.say();

//        Bzz b = new Bzz();
//        Czz c = (Czz)b;

        Czz c1 = new Czz();
        Bzz c1b = c1;
        c1b.say();
        Azz c1ba = c1b;
        c1ba.say();
        Azz c1a = c1;
        c1a.say();

    }
}


class Azz{
    void say(){
        System.out.println("Azz");
    }
}

class Bzz extends Azz{
    void say(){
        System.out.println("Bzz");
    }

}
class Czz extends Bzz{
    void say(){
        System.out.println("Czz");
    }
}










